package cn.tedu._05weibo.config;

import cn.tedu._05weibo.Interceptors.LoginCheckInterceptor;
import cn.tedu._05weibo.Interceptors.MyInterceptor1;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //1.拦截所有请求
        /*registry.addInterceptor(new MyInterceptor1());*/
        //2.拦截微博模块所有请求
        /*registry.addInterceptor(new MyInterceptor1())
                .addPathPatterns("/v1/weibo/**");*/
        //3.拦截评论模块除selectByWeiboId
        /*registry.addInterceptor(new MyInterceptor1())
                .addPathPatterns("/v1/comment/**")
                .excludePathPatterns("/v1/comment/selectByWeiboId");*/
        //拦截登录
        registry.addInterceptor(new LoginCheckInterceptor())
                .addPathPatterns("/v1/weibo/insert","/v1/comment/insert");
    }
}
